﻿using System;
using System.Collections.Generic;
using System.Text;
using FFIV.Lib.DataComponent;
using FFIV.Lib.DataComponent.CategoryDSTableAdapters;
using FFIV.Lib.Utilities;

namespace FFIV.Lib.BusinessRules
{
	internal class CategoriesRules
	{
		internal static void AddCategory(string name, int articleCount, int parentId)
		{
			CategoriesUtility.DisableCache();
			using (QueriesTableAdapter adapter = new QueriesTableAdapter())
			{
				adapter.AddCategory(name, articleCount, parentId);
			}
		}

		internal static void UpdateCategory(int categoryId, string name)
		{
			CategoriesUtility.DisableCache();
			using (QueriesTableAdapter adapter = new QueriesTableAdapter())
			{
				adapter.UpdateCategory(categoryId, name);
			}
		}

		internal static CategoryDS.CategoriesDataTable GetAllCategories()
		{
			using (CategoriesTableAdapter adapter = new CategoriesTableAdapter())
			{
				return adapter.GetAllCategories();
			}
		}

		internal static void DeleteCategoryById(int categoryId)
		{
			CategoriesUtility.DisableCache();
			using(QueriesTableAdapter adapter = new QueriesTableAdapter())
			{
				adapter.DeleteCategoryById(categoryId);
			}
		}
	}
}
